/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.cggveritas.crewintranet.jms.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author Alassane
 */
@Entity
@Table(name = "cv_typemodel")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CvTypemodel.findAll", query = "SELECT c FROM CvTypemodel c"),
    @NamedQuery(name = "CvTypemodel.findByIdcvTypemodel", query = "SELECT c FROM CvTypemodel c WHERE c.idcvTypemodel = :idcvTypemodel"),
    @NamedQuery(name = "CvTypemodel.findByModel", query = "SELECT c FROM CvTypemodel c WHERE c.model = :model")})
public class CvTypemodel implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idcv_typemodel")
    private Integer idcvTypemodel;
    @Basic(optional = false)
    @Column(name = "model")
    private String model;
    @JoinColumn(name = "cv_model_idmodel", referencedColumnName = "idmodel")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private CvModel cvModelIdmodel;
    @OneToMany(mappedBy = "typemodel", fetch = FetchType.LAZY)
    private List<CvVehicule> cvVehiculeList;

    public CvTypemodel() {
    }

    public CvTypemodel(Integer idcvTypemodel) {
        this.idcvTypemodel = idcvTypemodel;
    }

    public CvTypemodel(Integer idcvTypemodel, String model) {
        this.idcvTypemodel = idcvTypemodel;
        this.model = model;
    }

    public Integer getIdcvTypemodel() {
        return idcvTypemodel;
    }

    public void setIdcvTypemodel(Integer idcvTypemodel) {
        this.idcvTypemodel = idcvTypemodel;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public CvModel getCvModelIdmodel() {
        return cvModelIdmodel;
    }

    public void setCvModelIdmodel(CvModel cvModelIdmodel) {
        this.cvModelIdmodel = cvModelIdmodel;
    }

    @XmlTransient
    @JsonIgnore
    public List<CvVehicule> getCvVehiculeList() {
        return cvVehiculeList;
    }

    public void setCvVehiculeList(List<CvVehicule> cvVehiculeList) {
        this.cvVehiculeList = cvVehiculeList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idcvTypemodel != null ? idcvTypemodel.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CvTypemodel)) {
            return false;
        }
        CvTypemodel other = (CvTypemodel) object;
        if ((this.idcvTypemodel == null && other.idcvTypemodel != null) || (this.idcvTypemodel != null && !this.idcvTypemodel.equals(other.idcvTypemodel))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.cggveritas.crewintranet.jms.entities.CvTypemodel[ idcvTypemodel=" + idcvTypemodel + " ]";
    }
    
}
